const {
    electronicScore,
    foodScore,
    semiconductorScore,
    softwareScore,
    householdScore,
    metalScore,
    tourismScore,
    constructionScore,
    gasScore,
    engineeringConsultingScore,
    waterScore,
    culturalMediaScore,
    solarEquipmentScore,
    nonMetalMaterialScore,
    computerEquipmentScore,
    electronicChemicalScore,
    environmentalProtectionScore,
    opticalElectronicScore,
    chemicalRawScore,
    miningIndustryScore,
    autoPartsScore,
    communicationEquipmentScore,
    powerEquipmentScore,
    decorationConstructionScore,
    pesticideDrugScore,
    rubberProductScore,
    electronicComponentScore,
    smallMetalScore,
    windPowerEquipmentScore,
    beautyCareScore,
    preciousMetalScore,
    aerospaceScore,
    householdLightIndustryScore,
    plasticScore,
    tradeScore,
    glassScore,
    fertilizerScore,
    energyMetalScore,
    packagingScore,
    commercialScore,
    motorScore,
    chemicalFiberScore,
    carServiceScore,
    petroleumScore,
    steelScore,
    paperScore,
    realEstateServiceScore,
    medicalBusinessScore,
    jewelryScore,
    carScore,
    bankScore,
    airportScore,
    realEstateScore,
    publicUtilityScore,
    powerScore,
    railwayScore,
    decorationScore,
    multipleFinanceScore,
    cementScore,
    brewingScore,
    chineseMedicineScore,
    communicationServiceScore,
    generalEquipmentScore,
    engineeringMachineryScore,
    agriculturalFeedScore,
    internetServiceScore,
    chemicalProductScore,
    medicalServiceScore,
    batteryScore,
    logisticsScore,
    professionalServiceScore,
    transportationEquipmentScore,
    educationScore,
    biologicalProductScore,
    shipbuildingScore,
    instrumentScore,
    chemicalPharmacyScore,
    textileClothingScore,
    specialEquipmentScore,
    medicalDeviceScore,
    gameScore,
    gridEquipmentScore,
    insuranceScore,
    portScore,
    securitiesScore,
    generalScore,
    culturalEntertainmentScore
} = require('./sector');

// 换手率（10分）市盈率（10分）市净率（10分）流通市值（5分）净资产收益率（10分）资产负债率（10分）
function switchSector({ turnoverRate, pe, pb, marketValue, sector, roe, ratio }) {
    let score = 0;
    switch (sector) {
        case '电网设备':
            score += gridEquipmentScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '游戏':
            score += gameScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '医疗器械':
            score += medicalDeviceScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '专用设备':
            score += specialEquipmentScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '纺织服装':
            score += textileClothingScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '化学制药':
            score += chemicalPharmacyScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '仪器仪表':
            score += instrumentScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '船舶制造':
            score += shipbuildingScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '生物制品':
            score += biologicalProductScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
        case '教育':
            score += educationScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '交运设备':
            score += transportationEquipmentScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '专业服务':
            score += professionalServiceScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '物流行业':
            score += logisticsScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '电池':
            score += batteryScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '医疗服务':
            score += medicalServiceScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '互联网服务':
            score += internetServiceScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '化学制品':
            score += chemicalProductScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '农牧饲渔':
            score += agriculturalFeedScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '工程机械':
            score += engineeringMachineryScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '通用设备':
            score += generalEquipmentScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '通信服务':
            score += communicationServiceScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '中药':
            score += chineseMedicineScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '文化传媒':
            score += culturalMediaScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '光伏设备':
            score += solarEquipmentScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '非金属材料':
            score += nonMetalMaterialScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '计算机设备':
            score += computerEquipmentScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '电子化学品':
            score += electronicChemicalScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '环保行业':
            score += environmentalProtectionScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '光学光电子':
            score += opticalElectronicScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '化学原料':
            score += chemicalRawScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '煤炭行业':
        case '采掘行业':
            score += miningIndustryScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '汽车零部件':
            score += autoPartsScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '通信设备':
            score += communicationEquipmentScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '电源设备':
            score += powerEquipmentScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '装修建材':
            score += decorationConstructionScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '农药兽药':
            score += pesticideDrugScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '橡胶制品':
            score += rubberProductScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '电子元件':
            score += electronicComponentScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '小金属':
            score += smallMetalScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '风电设备':
            score += windPowerEquipmentScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '美容护理':
            score += beautyCareScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '贵金属':
            score += preciousMetalScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '旅游酒店':
            score += tourismScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '航天航空':
            score += aerospaceScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '家电行业':
            score += householdScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '家用轻工':
            score += householdLightIndustryScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '塑料制品':
            score += plasticScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '贸易行业':
            score += tradeScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '玻璃玻纤':
            score += glassScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '化肥行业':
            score += fertilizerScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '能源金属':
            score += energyMetalScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '包装材料':
            score += packagingScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '工程建设':
            score += constructionScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '商业百货':
            score += commercialScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '电机':
            score += motorScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '化纤行业':
            score += chemicalFiberScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '汽车服务':
            score += carServiceScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '石油行业':
            score += petroleumScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '钢铁行业':
            score += steelScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '造纸印刷':
            score += paperScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '房地产服务':
            score += realEstateServiceScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '医药商业':
            score += medicalBusinessScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '珠宝首饰':
            score += jewelryScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '汽车整车':
            score += carScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '银行':
            score += bankScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '航空机场':
            score += airportScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '房地产开发':
            score += realEstateScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '公用事业':
            score += publicUtilityScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '电力行业':
            score += powerScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '铁路公路':
            score += railwayScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '航运港口':
            score += portScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '证券':
            score += securitiesScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '综合行业':
            score += generalScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '多元金融':
            score += multipleFinanceScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '酿酒行业':
            score += brewingScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '水泥建材':
            score += cementScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '保险':
            score += insuranceScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '水务':
            score += waterScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '文化旅游休闲':
            score += culturalEntertainmentScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '工程咨询服务':
            score += engineeringConsultingScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '燃气':
            score += gasScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '装修装饰':
            score += decorationScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '消费电子':
            score += electronicScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '食品饮料':
            score += foodScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '半导体':
            score += semiconductorScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '软件开发':
            score += softwareScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        case '有色金属':
            score += metalScore({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
        default:
            score += defaultSector({ turnoverRate, pe, pb, marketValue, roe, ratio });
            break;
    }

    return score;
}

function defaultSector({ turnoverRate, pe, pb, marketValue, roe, ratio }) {
    let score = 0;
    // 2.1 市盈率（10分）
    if (pe > 0) {
        if (pe < 10) score += 10;
        else if (pe < 20) score += 7;
        else if (pe < 30) score += 3;
        else if (pe > 50) score -= 10;
        else if (pe > 30) score -= 5;
    }

    // 2.2 市净率（10分）
    if (pb > 0) {
        if (pb < 1) score += 10;
        else if (pb < 1.5) score += 7;
        else if (pb < 3) score += 3;
        else if (pb > 5) score -= 10;
        else if (pb > 3) score -= 5;
    }

    // 2.3 流通市值（5分）
    if (marketValue >= 5e9 && marketValue <= 2e10) score += 5;

    // 2.4 换手率（10分）
    if (turnoverRate >= 4 && turnoverRate <= 10) {
        score += 10;
    } else if (turnoverRate > 10) {
        score += turnoverRate <= 15 ? 5 : -5; // 10%-15%部分加分，超过扣分
    } else {
        score -= 3; // 低于4%扣分
    }

    // 2.5 净资产收益率（10分）
    if (roe >= 10 && roe <= 25) score += 10;
    // 2.6 资产负债率（10分）
    if (ratio >= 40 && ratio <= 70) score += 10;

    return score;
}

module.exports = { switchSector };
